<?
        require_once '../Navigation/functions.php';
        require_once 'data.php';
        $section='Shopping Cart';
        if(mysql_num_rows($get)!=0 & isset($_REQUEST['Name']) &  )
        {
            echo "problem";
                $rs = $_REQUEST;
                $errors = Validate($rs);
                if(!$errors)
                        $errors = Save($rs);
                if(!$errors)
                {
                        header("Location: index.php?new_id=$rs[id]");
                }
        }
        elseif(isset($_REQUEST['id']))
                $rs = Get($_REQUEST['id']);
        else
                $rs = Blank();
                
        $resultsUesrs = Users::GetAll();
        echo "problem";
?>

<!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Contact Methods</title>
        <style type="text/css">
                        .error { color: red; }
                        input.error {
                                border: 1px solid red;
                                background: #FEE;
                        }
                </style>
    </head>
    
    <body>
                <? include("../Navigation/tabs.php"); ?>
        
        <h1>Edit a Contact Method</h1>
        <ul class="error">
                <? foreach($errors as $field => $error){ ?>
                <li><?=$field?>: <?=$error?></li>
            <? } ?>
        </ul>
        
        <form method="post" action="" autocomplete="on">
        
        <label for="Name">Item Name:</label>
              <input  type="text"
                        name="Name" id="Name"
                    value="<?=$rs['Name']?>"
                    class="<?=isset($errors['Name']) ? 'error' : '' ?>" />
              <span class="error"><?=$errors['Name']?></span>      
             <label for="created_at">Created at:</label>
                <input  type="datetime"
                        name="created_at" id="created_at"
                    value="<?=$rs['created_at']?>"
                    class="<?=isset($errors['created_at']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['created_at']?></span>
            <br />
                <label for="updated_at">Updated at:</label>
                <input  type="datetime"
                        name="updated_at" id="updated_at"
                    value="<?=$rs['updated_at']?>"
                    class="<?=isset($errors['updated_at']) ? 'error' : '' ?>" />
            <span class="error"><?=$errors['updated_at']?></span>
            <br />

                <label for="User_id">User:</label>
            <select size="2" name="User_id" id="User_id"
                    class="<?=isset($errors['User_id']) ? 'error' : '' ?>" >
                <? while($rsUsers = $resultsUesrs->fetch_assoc()){ ?>
                    <option value="<?=$rsUsers['id']?>" 
                                <? if($rsUsers['id'] == $rs['User_id']){ ?>
                                selected="selected"
                            <? } ?>
                    >
                                                <?=$rsUsers['FirstName']?> <?=$rsUsers['LastName']?>
                     </option>
                                <? } ?>
            </select>
            <span class="error"><?=$errors['User_id']?></span>
                     
                <br />
                <label for="Lookup_id">Lookup_id:    </label>
                <input  type="number"
                        name="Lookup_id" id="Lookup_id"
                    value="<?=$rs['Lookup_id']?>"
                    class="<?=isset($errors['Lookup_id']) ? 'error' : '' ?>" />               
                <br />
            
            <input type="hidden" value="true"  name="Save"/>
            <input type="submit" value="Save"/>
            <a href="#" class="cancel">Cancel</a>
       </form>

        </div>
        </ul>
        </body>
</html>

